<html ng-app="app">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="resources/bootstrap/css/bootstrap.min.css">
    <link rel="stylesheet" href="css/common.css">
    <link rel="stylesheet" href="resources/weui/style/weui.min.css">
    <script src="resources/jquery.min.js"></script>
    <script src="resources/bootstrap/js/bootstrap.min.js"></script>
    <script src="resources/angular/angular.min.js"></script>
    <script src="resources/angular/angular-animate.min.js"></script>
    <script src="resources/angular/angular-sanitize.min.js"></script>
    <title>活动投票</title>
</head>
<body ng-controller="myCtrl" style="background-color: #eee;">
<div class="result-kai text-center">
    <div class="circle"><b>開</b></div>
</div>
<h3 class="text-center" ng-show="!flag"><b>感谢参与！！！</b></h3>
<h3 class="text-center" ng-show="flag"><b ng-bind="'恭喜您获得“'+prize.title+'”'+prize.description"></b></h3>
<div class="text-center" style="margin-top: 10%;margin-bottom: 15px;font-size: .9em;" ng-show="flag">
    请在9月6日17:30前到GT4-17B01进行奖品兑换，逾期不候；
</div>
<div class="text-center" style="margin-top: 10%;margin-bottom: 15px;" ng-show="flag">
    <button type="button" class="btn btn-danger  btn-lg" ng-click="submit()" ng-show="!hasExchange">兑换奖品</button>
    <button type="button" class="btn btn-warning  btn-lg" ng-show="hasExchange">奖品已兑换</button>
</div>
<div class="alert alert-warning" role="alert" style="font-size: 11.9px;margin-left: 20px;margin-right: 20px;"
     ng-show="flag">
    请出示该页面给工作人员，并由工作人员点击兑换按钮，进行礼品兑换！
</div>

<div class="modal fade bs-example-modal-lg" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel"
     ng-show="flag">
    <div class="modal-dialog modal-lg" role="document">
        <div class="modal-content"
             style="background-color: #ab2626;color: #CA986C;margin-top: 50%;height: 120px;">
            <div class="text-center" style="font-size: 2em;padding-top: 8%;">您的兑换码为：
                <div style="display:inline-block;" ng-bind="code"></div>
            </div>
            <div class="text-center" style="margin-top: 10px;" ng-show="hasExchange">（已兑换）</div>
            <div class="text-center" style="margin-top: 10px;" ng-show="!hasExchange">（未兑换）</div>
        </div>
    </div>
</div>
<script>
    function getContextPath() {
        var pathName = document.location.pathname;
        var index = pathName.substr(1).indexOf("/");
        var result = pathName.substr(0, index + 1);
        return result;
    }
    var ctx = getContextPath();
    var app = angular.module('app', []);
    app.controller('myCtrl', ['$scope', '$http', function ($scope, $http) {
        $scope.prize = {};
        $scope.code = '';
        $scope.flag = false;
        $scope.hasExchange = false;
        $http.get(ctx + '/exchange/showPrice').then(function (resp) {
            console.log(resp.data);
            if (resp.data) {
                $scope.prize = resp.data.prize;
                $scope.code = resp.data.code;
                $scope.flag = true;
                if (resp.data.hasExchange) $scope.hasExchange = true;
            }
        });
        $scope.submit = function () {
            $('.modal').modal({});
        }
    }]);
</script>
</body>